import axios from 'axios'

const service = axios.create({
  baseURL: '/api', // 根据后端API前缀调整
  timeout: 5000
})

// 请求拦截器：自动带token
service.interceptors.request.use(
  config => {
    const token = localStorage.getItem('token')
    if (token) {
      config.headers['Authorization'] = 'Bearer ' + token
    }
    return config
  },
  error => Promise.reject(error)
)

export default service 